from pygds import GDS
import pandas as pd

URI = "bolt://localhost:7687"
AUTH = ("neo4j", "123456")


# 参数链接 https://neo4j.com/docs/graph-data-science/current/alpha-algorithms/random-walk/
with GDS(URI, auth=AUTH) as gds:
    result = gds.alpha.randomWalk.stream(
    {
        'nodeQuery':"match (n:`企业`) -[r:`投标`]->(m:`工程项目标段`) return distinct id(n) as id",
        'relationshipQuery':"match (n:`企业`) -[r:`投标`]->(m:`工程项目标段`)<-[b:`投标`]-(a:`企业`)  return id(n) as source,id(a) as  target",
        'steps':10,
        'walks':200000,
        'mode':"node2vec",
        'return':1,
        'inOut':2
    })

    _tmp = pd.DataFrame.from_records(result)
    _tmp.to_csv("random_walk.csv")


